package br.com.registrofinancas.controller;

import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;
import br.com.registrofinancas.R;
import br.com.registrofinancas.view.FinancasActivity;

public class FinancasActivityTabsController implements OnTabChangeListener {

	private TabHost mTabHost;
	private final FinancasActivity financasActivity;
	
	public FinancasActivityTabsController(TabHost myTabHost, FinancasActivity financasActivity) {
		this.mTabHost = myTabHost;
		this.financasActivity = financasActivity;
		mTabHost.setCurrentTab(1);
		mTabHost.setOnTabChangedListener(this);
	}

	
	@Override
	public void onTabChanged(String tabId) {
		switch (mTabHost.getCurrentTab()) {
        case 0:  // TAB GANHOS
        	ListView listViewGanhos = (ListView) financasActivity.findViewById(R.id.financas_lista_ganhos_lv_ganhos);
        	FinancasActivityGanhosController.getInstance().setInitDadosTab(financasActivity, listViewGanhos);       	
             break;
        case 1: // TAB GASTOS
        	ListView listViewGastos = (ListView) financasActivity.findViewById(R.id.financas_lista_gastos_lv_gastos);    		
        	FinancasActivityGastosController.getInstance().setInitDadosTab(financasActivity, listViewGastos);            
            break;
        case 2: // TAB TOTAIS
        	FinancasActivityTotaisController.getInstance().setTab(financasActivity);
            break;
        default:       	
            break;
        }
	}

	// adicionando tab em TabHost 
	public void addTabs(TabSpec specGanhos, TabSpec specGastos,	TabSpec specTotais) {
		mTabHost.addTab(specGanhos);
		mTabHost.addTab(specGastos);
		mTabHost.addTab(specTotais);
	}

}
